
import util from "../../common/js/util.js";
var app = getApp();

Component({
  mixins: [],
  data: {
    maskState: 0,
    content: "",
    focus: false
  },
  props: {
    btnList: Object,
    placeholder: String,
    fileList: {
      type: [Array, Boolean],
      default: false
    },
    onPubComment: function onPubComment(e){}
  },
  didMount() { },
  didUpdate() { },
  didUnmount() { },
  methods: {
    stopPrevent() { },
    toggleMask(type) {
      let timer = type == 'show' ? 10 : 300;
      let state = type == 'show' ? 1 : 0;
      //debugger
      // this.maskState = 2;
      let that=this;
     // setTimeout(() => {
       // this.maskState = state;
        let focus=false;
        // #ifdef APP-PLUS
        // 安卓app软键盘自动弹出有点问题，暂时还没有很好的解决方案，所以就禁止安卓app软键盘自动弹出，如果哪位朋友有好的解决方案可以在评论里告诉大家参考一下
        if (dd.getSystemInfoSync().platform == "ios") {
          focus = state ? true : false;
        }
        // #endif
        // #ifndef APP-PLUS
        focus = state ? true : false;
        this.setData({
          maskState:state,
          focus
        })
        // #endif
     // }, timer);

      if (type != "show") {
        this.pubCommentClose()
      };
    },
    bindKeyInput(e) {
      let key = e.currentTarget.dataset.key;
      this.setData({
        [`${key}`]: e.detail.value,
      });
    },
    onPubComment() {
      this.props.onPubComment(this.data.content)
     // this.$emit("pubComment", this.data.content);
    },
    clearContent(){
      this.setData({
        content:"",
        maskState:0,
      })
    },
    // 评论区按钮
    trigger(func) {
      this.$emit(func);
    },
    // 关闭评论弹层
    pubCommentClose() {
      this.clearContent();
    }
  },
});
